package mylittleinvestigations.Events;

import java.util.ArrayList;
import mylittleinvestigations.GameUi.ButtonArray;

public class ButtonArrayEventProvider
{
    private static ArrayList<ButtonArrayEventListener> listenerList = new ArrayList<ButtonArrayEventListener>();
    
    public static void RegisterListener(ButtonArrayEventListener listener)
    {
        if (!listenerList.contains(listener))
        {
            listenerList.add(listener);
        }
    }
    
    public static void ClearListener(ButtonArrayEventListener listener)
    {
        listenerList.remove(listener);
    }
    
    public static void RaiseButtonClicked(ButtonArray sender, int id)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnButtonArrayButtonClicked(sender, id);
        }
    }
    
    public static void RaiseCanceled(ButtonArray sender)
    {
        for (int i = 0; i < listenerList.size(); i++)
        {
            listenerList.get(i).OnButtonArrayCanceled(sender);
        }
    }
}
